package ws.jdbc.concurrent.test.tasks.update;

import java.sql.ResultSet;
import java.sql.SQLException;
import ws.jdbc.concurrent.eresultset.EResultSet;
import ws.jdbc.concurrent.exception.JdbcConcurrentException;
import ws.jdbc.concurrent.test.tasks.EResultSetRunnable;

/**
 * This task update data from a {@link ResultSet} using an {@link EResultSet}.
 * 
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public class EResultSetUpdate extends EResultSetRunnable {

  public EResultSetUpdate() throws JdbcConcurrentException {
    super();
  }

  public void run() {
    try {
      while (cursor.next()) {
        cursor.updateInt(1, num);
        cursor.updateString(2, str1);
        cursor.updateString(3, str2);
        cursor.updateFloat(4, decimal);
        cursor.updateRow();
      }
    } catch (SQLException ex) {
      throw new RuntimeException(ex);
    }
  }
}
